package com.bops.dal.user.dao.impl;

import java.util.HashMap;
import java.util.List;

import com.bops.cache.UserCache;
import com.bops.dal.user.dao.RenyuaninfoDAO;
import com.bops.dal.user.dataobject.RenyuaninfoDO;
import com.bops.dal.user.queryobject.UserQuery;
import com.yue.commons.db.ibatis.YueBaseSqlMapClientDaoSupport;

public class RenyuaninfoDAOImpl extends YueBaseSqlMapClientDaoSupport  implements RenyuaninfoDAO {

	public int countRenyuaninfo(HashMap<String, Object> map) {
		return (Integer) getSqlMapClientTemplate().queryForObject("REN_YUAN_INFO.count_RenYuanInfo", map);
	}

	public int deleteByEngId(String engId) {
		HashMap<String,String> map = new HashMap<String,String>();
		map.put(UserQuery.ENG_ID,engId);
		int rows = getSqlMapClientTemplate().delete("REN_YUAN_INFO.delete", map);
		UserCache.clean();
		return rows;
	}

	public void insert(RenyuaninfoDO record) {
		getSqlMapClientTemplate().insert("REN_YUAN_INFO.insert", record);
		UserCache.clean();
	}

	@SuppressWarnings("unchecked")
	public List<RenyuaninfoDO> listRenyuaninfo(HashMap<String, Object> map) {
		return getSqlMapClientTemplate().queryForList("REN_YUAN_INFO.list_RenYuanInfo", map);
	}
	
	@SuppressWarnings("unchecked")
    public List<RenyuaninfoDO> listRenyuaninfo(UserQuery query)
    {
	    if (query==null)
	    {
	        query = new UserQuery();
	        query.setPageSize(Integer.MAX_VALUE);
	    }
        return getSqlMapClientTemplate().queryForPagination("REN_YUAN_INFO.count_by_query",
                                                            "REN_YUAN_INFO.select_by_query", query);
        
    }
	
	@SuppressWarnings("unchecked")
	public List<RenyuaninfoDO> listWake(HashMap<String, Object> map) {
		return getSqlMapClientTemplate().queryForList("REN_YUAN_INFO.list_wake", map);
	}

	public int updateRenyuaninfo(RenyuaninfoDO record) {
		int rows = getSqlMapClientTemplate().update("REN_YUAN_INFO.update", record);
		UserCache.clean();
		return rows;
	}
	
	public int updateRenyuaninfoAgePay(RenyuaninfoDO record) {
		int rows = getSqlMapClientTemplate().update("REN_YUAN_INFO.updateAgePay", record);
		UserCache.clean();
		return rows;
	}
}
